package cn.edu.nuc.android.oweibo.activities;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import cn.edu.nuc.android.oweibo.OWeiboApplication;
import cn.edu.nuc.android.oweibo.R;

public class AuthorizationActivity extends Activity {

	private OWeiboApplication app;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.authorization_view);
		app = (OWeiboApplication)getApplication();
		
		authorize();
	}

	/**
	 * 用户授权并转向主页面
	 */
	private void authorize() {
		Uri uri = this.getIntent().getData();
		String pin = uri.getQueryParameter("oauth_verifier");
		app.authorize(pin);
		if (app.isAuthorized()) {
			Intent intent = new Intent(this, StatusListActivity.class);
			startActivity(intent);
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

}
